import json

from com.maycur.gateway.common.base_entity import ApiTaskSet
from locust import task


class LegalEntityTask(ApiTaskSet):

    @task(1)
    def list_legal_entity(self):
        list_legal_entity_url = f'{self.get_app_host()}/api/web/legal-entity-setting'
        request_body = {
            "keyword": "",
            "scopeType": "LEGAL_ENTITY",
            "length": 100,
            "start": 0
        }
        json_body = json.dumps(request_body)
        headers = self.get_headers_with_content_type()
        with self.client.post(list_legal_entity_url, data=json_body, headers=headers, catch_response=True) as res:
            self.parse_response(res)
